/*
This file is part of Cafca.

Cafca is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cafca is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Cafca.  If not, see <http://www.gnu.org/licenses/>.

If you have any comment, suggestion or idea, do not hesitate to contact me at shenrotin@gmail.com
*/

package org.crag.cafca.gui;

import org.apache.log4j.Logger;
import org.crag.cafca.util.Constants;
import org.w3c.dom.Element;

public class Menu extends Submenu
{ 
	/**
	 * Logger log4j. See log4j doc for more information.
	 */
	private static Logger log=Logger.getLogger(new Throwable().getStackTrace()[0].getClassName());
		
	public Menu()
	{
		super();
		this.id="root";
		this.name="System";
	}
	
	public Submenu findSubmenu(String id) 
	{
		if (id.equals("root"))
			return this;

		String[] splittedId=id.split(Constants.PATH_SEPARATOR);
		Submenu currentSubsystem=this;
		for (int i=1;i<splittedId.length;i++)
		{
			currentSubsystem=currentSubsystem.findChild(splittedId[i]);
		}
		
		return currentSubsystem;
	}
}
